package com.google.codejam.storecredit;

import com.google.codejam.core.test.ACodeJamTestCase;
import com.google.codejam.core.test.ACodeJamTestSuiteRunner;

import java.io.IOException;

/**
 * Concrete implementation of the <code>ACodeJamTestSuiteRunner</code> for the
 * "Minimum Scalar Product" problem.
 */
public class StoreCreditTestSuiteRunner extends ACodeJamTestSuiteRunner
{
	public StoreCreditTestSuiteRunner(String test_suite_name)
	{
		super(test_suite_name);
	}

	/**
	 * Reads enough from the input to instantiate a concrete instance of a
	 * <code>ACodeJamTestCase</code>, <code>MinimumScalarProductTestCase</code>
	 * in this case. Each test case consists of three lines from the input file:
	 * <ul>
	 *    <li>Line 1 - Contains store credit.</li>
	 *    <li>Line 2 - Contains the number of store items.</li>
	 *    <li>Line 3 - Contains the respective prices of the store items.</li>
	 * </ul>
	 *
	 * @return Instantiated <code>ACodeJamTestCase</code> instance.
	 * @throws IOException
	 */
	@Override
	protected ACodeJamTestCase initNextTestCaseFromInput()
			  throws IOException
	{
		int store_credit = Integer.parseInt(input_reader.readLine());
		int number_of_items = Integer.parseInt(input_reader.readLine());
		String item_prices = input_reader.readLine();

		ACodeJamTestCase test_case =
				  new StoreCreditTestCase(store_credit, number_of_items);

		test_case.parseDataString(item_prices);

		return test_case;
	}
}
